import 'package:appflutterhomeschool/model/payment_list_model.dart';
import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/colors.dart';
import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/ui/widgets/button_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/my_app_bar.dart';
import 'package:appflutterhomeschool/ui/widgets/user/item_customization_widget.dart';
import 'package:appflutterhomeschool/view_model/my/confirm_corder_view_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///用户： ninetailedfox
///时间： 2020/7/4
///邮箱： 1037438704@qq.com
///功能： 确认订单
class ConfirmCorderPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ProviderWidget<ConfirmCorderViewPage>(
      model: ConfirmCorderViewPage(context),
      onModelReady: (value) => value.initView(),
      builder: (context, viewModel, child) {
        return Scaffold(
          backgroundColor: Colours.gray_f5,
          appBar: MyAppBar2(title: "确认订单"),
          body: Column(
            children: <Widget>[
              Container(
                padding: EdgeInsets.only(bottom: 10),
                color: Colors.white,
                child: ItemCustomizationWidget(
                  visibleBool1: false,
                  visibleBool2: true,
                  textStyleBottom: TextStyles.textOrange37,
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 0.3),
                color: Colors.white,
                padding: EdgeInsets.all(ScreenUtil().setWidth(34)),
                alignment: Alignment.centerRight,
                child: Text.rich(TextSpan(children: [
                  TextSpan(text: "实付款：", style: TextStyles.textOrange30),
                  TextSpan(text: "￥155", style: TextStyles.textOrange43),
                ])),
              ),
              Container(
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
                margin: EdgeInsets.only(top: 10),
                color: Colors.white,
                child: Text("支付方式", style: TextStyles.textDark37),
              ),
              ListView.builder(
                  itemCount: paymentList.length,
                  shrinkWrap: true,
                  physics: NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) {
                    return Container(
                      color: Colors.white,
                      child: ListTile(
                        title: Text(paymentList[index].title),
                        subtitle: Text(paymentList[index].context),
                        leading: Image.asset(paymentList[index].imageUrl),
                        trailing: Visibility(
                          visible: paymentList[index].iconBool,
                          child: Icon(Icons.check_circle,
                              color: Colors.blue, size: 15),
                        ),
                        onTap: () => viewModel.payOnTapList(index),
                      ),
                    );
                  }),
              Expanded(child: Container()),
              ButtonWidget().rectangleButtonWidget(
                  buttonName: "确认支付",
                  onPressed: () {
                    Navigator.of(context).pop();
                  }),
            ],
          ),
        );
      },
    );
  }
}
